package de.shortys.myhome.api.view.tree;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicScrollBarUI;

public class ModuleViewTreeScrollbarUI extends BasicScrollBarUI {
	private int orientation = HORIZONTAL;

	public ModuleViewTreeScrollbarUI(int oprientation) {
		this.orientation = oprientation;
	}

	@Override
	public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
		g.setColor(new Color(21, 66, 139));
		g.translate(thumbBounds.x, thumbBounds.y);

		if (orientation == VERTICAL) {
			int w = 2;
			int h = thumbBounds.height;
			g.fillRect(thumbBounds.width - w * 2, 0, w, h);
		} else if (orientation == HORIZONTAL) {
			int w = 2;
			int h = thumbBounds.height;
			g.fillRect(0, h - w * 2, thumbBounds.width, w);
		} else {
			throw new IllegalArgumentException("orientation not supported: "
					+ orientation);
		}

	}

	@Override
	public void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
		// Track wird nicht gebraucht.
	}
}
